{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-08-18T10:26:21.206824Z",
     "start_time": "2025-08-18T10:26:10.210161Z"
    }
   },
   "source": [
    "from langchain_core.messages import SystemMessage, HumanMessage\n",
    "from langchain_openai import ChatOpenAI\n",
    "import os\n",
    "chatLLM = ChatOpenAI(\n",
    "    # 若没有配置环境变量，请用百炼API Key将下行替换为：api_key=\"sk-xxx\",\n",
    "    api_key=os.getenv(\"DASH_SCOPE_API_KEY\"), # 如何获取API Key：https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key\n",
    "    base_url=\"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n",
    "    model=\"qwen-plus\",\n",
    "    temperature=0.8,\n",
    "    max_tokens=60,\n",
    ")\n",
    "\n",
    "messages = [\n",
    "    SystemMessage(content=\"你是一个很棒的智能助手\"),\n",
    "    HumanMessage(content=\"请给我的花店起个名\")\n",
    "]\n",
    "\n",
    "\n",
    "response = chatLLM.invoke(messages)\n",
    "print(response.content)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当然可以！给花店起名字是一件很有意思的事情，名字不仅要好听，还要能体现花店的风格和特色。你可以先告诉我一些信息，这样我可以帮你起一个更贴切的名字：\n",
      "\n",
      "1. **你的花店有什么风格**？比如：浪漫、复古、简约、文艺、森系、奢华等等。\n",
      "2. **主要售卖什么类型的花**？比如：玫瑰、永生花、进口花材、多肉植物、干花等等。\n",
      "3. **目标客户群体是谁**？比如：年轻人、情侣、商务人士、婚礼客户等。\n",
      "4. **你希望传达什么样的感觉或理念**？比如：爱、幸福、自然、治愈、永恒、个性等等。\n",
      "\n",
      "---\n",
      "\n",
      "### 如果你现在还不确定风格，我可以先给你一些通用又有意境的花店名参考：\n",
      "\n",
      "#### 🌹 温馨浪漫风：\n",
      "- 花间一壶酒  \n",
      "- 与花共此时  \n",
      "- 花语心愿  \n",
      "- 爱在花开时  \n",
      "- 花开正好\n",
      "\n",
      "#### 🌿 文艺自然风：\n",
      "- 野花集  \n",
      "- 山有木兮  \n",
      "- 花见山  \n",
      "- 半山花开  \n",
      "- 拾间花坊\n",
      "\n",
      "#### 💐 简约时尚风：\n",
      "- 花时间  \n",
      "- 花言馆  \n",
      "- 花屿  \n",
      "- 花未眠  \n",
      "- 花光十色\n",
      "\n",
      "#### 💍 高端定制风：\n",
      "- 花漾年华  \n",
      "- 花之殿堂  \n",
      "- 繁花似锦  \n",
      "- 名花有主  \n",
      "- 花间集\n",
      "\n",
      "#### 🌸 有诗意的名字：\n",
      "- 人间四月天  \n",
      "- 花落知多少  \n",
      "- 一束春光  \n",
      "- 花开成海  \n",
      "- 浮生若花\n",
      "\n",
      "---\n",
      "\n",
      "如果你告诉我更多关于你花店的信息，我可以帮你定制一个更符合你心意的名字！也可以加上英文名、LOGO设计建议等哦 😊\n"
     ]
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "de0081150db97bff"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
